package com.fjec.market.controller;

import com.fjec.common.protocol.JsonResult;
import com.fjec.common.view.ListItem;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.fjec.market.service.IInfoPccService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author admin
 * @since 2020-10-30
 */
@RestController
@RequestMapping("/")
public class InfoPccController {

    @Resource
    private IInfoPccService service;

    /**
     * 获取银盛省市区
     *
     * @param type 1=省 2=市 3=区
     * @param key
     * @return
     */
    @GetMapping("/n/get/ys/pcc")
    public JsonResult getProvCityCounty(@RequestParam("type") Integer type,
                                        @RequestParam(value = "key", required = false) String key) {
        List<ListItem> resultList = new ArrayList<>();
        switch (type) {
            case 1:
                resultList = service.getProv();
                break;
            case 2:
                resultList = service.getCity(key);
                break;
            case 3:
                resultList = service.getCounty(key);
                break;
        }
        return JsonResult.success()
                .data(resultList)
                .build();
    }
}
